home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / zerozone.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  9KB  |  278 lines

  1. /***************************************************************************
  2.  
  3. Zero Zone memory map
  4.  
  5. driver by Brad Oliver
  6.  
  7. CPU 1 : 68000, uses irq 1
  8.  
  9. 0x000000 - 0x01ffff : ROM
  10. 0x080000 - 0x08000f : input ports and dipswitches
  11. 0x088000 - 0x0881ff : palette RAM, 256 total colors
  12. 0x09ce00 - 0x09d9ff : video ram, 48x32
  13. 0x0c0000 - 0x0cffff : RAM
  14. 0x0f8000 - 0x0f87ff : RAM (unused?)
  15.  
  16. TODO:
  17.     * adpcm samples don't seem to be playing at the proper tempo - too fast?
  18.     * There are a lot of unknown dipswitches
  19.  
  20. ***************************************************************************/
  21. #include "driver.h"
  22. #include "vidhrdw/generic.h"
  23.  
  24. void zerozone_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh);
  25. int zerozone_vh_start(void);
  26. void zerozone_vh_stop(void);
  27. READ_HANDLER( zerozone_videoram_r );
  28. WRITE_HANDLER( zerozone_videoram_w );
  29.  
  30. extern unsigned char *zerozone_videoram;
  31. static unsigned char *ram; /* for high score save */
  32.  
  33. static READ_HANDLER( zerozone_input_r )
  34. {
  35.     switch (offset)
  36.     {
  37.         case 0x00:
  38.             return readinputport(0); /* IN0 */
  39.         case 0x02:
  40.             return (readinputport(1) | (readinputport(2) << 8)); /* IN1 & IN2 */
  41.         case 0x08:
  42.             return (readinputport(4) << 8);
  43.         case 0x0a:
  44.             return readinputport(3);
  45.     }
  46.  
  47. logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",cpu_get_pc(),0x800000+offset);
  48.  
  49.     return 0x00;
  50. }
  51.  
  52.  
  53. WRITE_HANDLER( zerozone_sound_w )
  54. {
  55.     soundlatch_w (offset, (data >> 8) & 0xff);
  56.     cpu_cause_interrupt (1, 0xff);
  57. }
  58.  
  59. static struct MemoryReadAddress readmem[] =
  60. {
  61.     { 0x000000, 0x01ffff, MRA_ROM },
  62.     { 0x080000, 0x08000f, zerozone_input_r },
  63.     { 0x088000, 0x0881ff, paletteram_word_r },
  64. //    { 0x098000, 0x098001, MRA_RAM }, /* watchdog? */
  65.     { 0x09ce00, 0x09d9ff, zerozone_videoram_r },
  66.     { 0x0c0000, 0x0cffff, MRA_BANK1 },
  67.     { 0x0f8000, 0x0f87ff, MRA_BANK2 },
  68.     { -1 }  /* end of table */
  69. };
  70.  
  71. static struct MemoryWriteAddress writemem[] =
  72. {
  73.     { 0x000000, 0x01ffff, MWA_ROM },
  74.     { 0x084000, 0x084001, zerozone_sound_w },
  75.     { 0x088000, 0x0881ff, paletteram_BBBBGGGGRRRRxxxx_word_w, &paletteram },
  76.     { 0x09ce00, 0x09d9ff, zerozone_videoram_w, &zerozone_videoram, &videoram_size },
  77.     { 0x0c0000, 0x0cffff, MWA_BANK1, &ram }, /* RAM */
  78.     { 0x0f8000, 0x0f87ff, MWA_BANK2 },
  79.     { -1 }  /* end of table */
  80. };
  81.  
  82.  
  83. static struct MemoryReadAddress sound_readmem[] =
  84. {
  85.     { 0x0000, 0x7fff, MRA_ROM },
  86.     { 0x8000, 0x87ff, MRA_RAM },
  87.     { 0x9800, 0x9800, OKIM6295_status_0_r },
  88.     { 0xa000, 0xa000, soundlatch_r },
  89.     { -1 }  /* end of table */
  90. };
  91.  
  92. static struct MemoryWriteAddress sound_writemem[] =
  93. {
  94.     { 0x0000, 0x7fff, MWA_ROM },
  95.     { 0x8000, 0x87ff, MWA_RAM },
  96.     { 0x9800, 0x9800, OKIM6295_data_0_w },
  97.     { -1 }  /* end of table */
  98. };
  99.  
  100. INPUT_PORTS_START( zerozone )
  101.     PORT_START      /* IN0 */
  102.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  103.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  104.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  105.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
  106.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
  107.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  108.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  109.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  110.  
  111.     PORT_START      /* IN1 */
  112.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY )
  113.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_4WAY )
  114.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_4WAY )
  115.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_4WAY )
  116.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  117.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  118.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
  119.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  120.  
  121.     PORT_START      /* IN2 */
  122.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER2 )
  123.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_4WAY | IPF_PLAYER2 )
  124.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_4WAY | IPF_PLAYER2 )
  125.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_4WAY | IPF_PLAYER2 )
  126.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  127.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  128.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  129.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  130.  
  131.     PORT_START /* DSW A */
  132.     PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
  133.     PORT_DIPSETTING(    0x00, DEF_STR( 6C_1C ))
  134.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ))
  135.     PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ))
  136.     PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ))
  137.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ))
  138.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ))
  139.     PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ))
  140.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ))
  141.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  142.     PORT_DIPSETTING(    0x08, DEF_STR( Off ))
  143.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  144.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  145.     PORT_DIPSETTING(    0x10, DEF_STR( Off ))
  146.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  147.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  148.     PORT_DIPSETTING(    0x20, DEF_STR( Off ))
  149.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  150.     PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Unknown ) )
  151.     PORT_DIPSETTING(    0xc0, "1")
  152.     PORT_DIPSETTING(    0x80, "2")
  153.     PORT_DIPSETTING(    0x40, "3")
  154.     PORT_DIPSETTING(    0x00, "4")
  155.  
  156.     PORT_START /* DSW B */
  157.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  158.     PORT_DIPSETTING(    0x01, DEF_STR( Off ))
  159.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  160.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  161.     PORT_DIPSETTING(    0x02, DEF_STR( Off ))
  162.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  163.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Unknown ) )
  164.     PORT_DIPSETTING(    0x0c, "1")
  165.     PORT_DIPSETTING(    0x04, "2")
  166.     PORT_DIPSETTING(    0x08, "3")
  167.     PORT_DIPSETTING(    0x00, "4")
  168.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  169.     PORT_DIPSETTING(    0x10, DEF_STR( Off ))
  170.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  171.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  172.     PORT_DIPSETTING(    0x20, DEF_STR( Off ))
  173.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  174.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  175.     PORT_DIPSETTING(    0x40, DEF_STR( Off ))
  176.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  177.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  178. INPUT_PORTS_END
  179.  
  180.  
  181. static struct GfxLayout charlayout =
  182. {
  183.     8,8,    /* 8*8 characters */
  184.     4096,    /* 4096 characters */
  185.     4,    /* 4 bits per pixel */
  186.     { 0, 1, 2, 3 },
  187.     { 0, 4, 8+0, 8+4, 16+0, 16+4, 24+0, 24+4 },
  188.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  189.     32*8    /* every sprite takes 32 consecutive bytes */
  190. };
  191.  
  192.  
  193. static struct GfxDecodeInfo gfxdecodeinfo[] =
  194. {
  195.     { REGION_GFX1, 0, &charlayout, 0, 256 },         /* sprites & playfield */
  196.     { -1 } /* end of array */
  197. };
  198.  
  199.  
  200. static struct OKIM6295interface okim6295_interface =
  201. {
  202.     1,              /* 1 chip */
  203.     { 8000 },           /* 8000Hz ??? TODO: find out the real frequency */
  204.     { REGION_SOUND1 },    /* memory region 3 */
  205.     { 100 }
  206. };
  207.  
  208. static struct MachineDriver machine_driver_zerozone =
  209. {
  210.     {
  211.         {
  212.             CPU_M68000,
  213.             10000000,    /* 10 MHz */
  214.             readmem,writemem,0,0,
  215.             m68_level1_irq,1
  216.         },
  217.         {
  218.             CPU_Z80 | CPU_AUDIO_CPU,
  219.             1000000,    /* 1 MHz ??? */
  220.             sound_readmem, sound_writemem,0,0,
  221.             ignore_interrupt,0    /* IRQs are triggered by the main cpu */
  222.         }
  223.     },
  224.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  225.     10,
  226.     0,
  227.  
  228.     /* video hardware */
  229.     48*8, 32*8, { 1*8, 47*8-1, 2*8, 30*8-1 },
  230.  
  231.     gfxdecodeinfo,
  232.     256, 256,
  233.     0,
  234.  
  235.     VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY | VIDEO_MODIFIES_PALETTE,
  236.     0,
  237.     zerozone_vh_start,
  238.     zerozone_vh_stop,
  239.     zerozone_vh_screenrefresh,
  240.  
  241.     /* sound hardware */
  242.     0,0,0,0,
  243.     {
  244.         {
  245.             SOUND_OKIM6295,
  246.             &okim6295_interface
  247.         }
  248.     }
  249. };
  250.  
  251.  
  252.  
  253. /***************************************************************************
  254.  
  255.   Game driver(s)
  256.  
  257. ***************************************************************************/
  258.  
  259. ROM_START( zerozone )
  260.     ROM_REGION( 0x20000, REGION_CPU1 )     /* 128k for 68000 code */
  261.     ROM_LOAD_EVEN( "zz-4.rom", 0x0000, 0x10000, 0x83718b9b )
  262.     ROM_LOAD_ODD ( "zz-5.rom", 0x0000, 0x10000, 0x18557f41 )
  263.  
  264.     ROM_REGION( 0x10000, REGION_CPU2 )      /* sound cpu */
  265.     ROM_LOAD( "zz-1.rom", 0x00000, 0x08000, 0x223ccce5 )
  266.  
  267.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  268.     ROM_LOAD( "zz-6.rom", 0x00000, 0x80000, 0xc8b906b9 )
  269.  
  270.     ROM_REGION( 0x40000, REGION_SOUND1 )      /* ADPCM samples */
  271.     ROM_LOAD( "zz-2.rom", 0x00000, 0x20000, 0xc7551e81 )
  272.     ROM_LOAD( "zz-3.rom", 0x20000, 0x20000, 0xe348ff5e )
  273. ROM_END
  274.  
  275.  
  276.  
  277. GAME( 1993, zerozone, 0, zerozone, zerozone, 0, ROT0, "Comad", "Zero Zone" )
  278.